<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<div class="text-center">
    <ul class="pagination pagination-sm">
        <c:choose>
            <c:when test="${page.firstPage}">
                <li class="disabled"><a href="#">First</a></li>
                <li class="disabled"><a href="#">&lt;</a></li>
            </c:when>
            <c:otherwise>
                <li><a href="${page.url}?page=0&size=${page.size}&sort=${page.sort}">First</a></li>
                <li><a href="${page.url}?page=${page.number-2}&size=${page.size}&sort=${page.sort}">&lt;</a></li>
            </c:otherwise>
        </c:choose>
        <c:forEach items="${page.items}" var="item">
            <c:choose>
                <c:when test="${item.current}">
                    <li class="active"><a href="${page.url}?page=${item.number-1}&size=${page.size}&sort=${page.sort}"><c:out value="${item.number}" /></a></li>
                </c:when>
                <c:otherwise>
                    <li><a href="${page.url}?page=${item.number-1}&size=${page.size}&sort=${page.sort}"><c:out value="${item.number}" /></a></li>
                </c:otherwise>
            </c:choose>
        </c:forEach>
        <c:choose>
            <c:when test="${page.lastPage}">
                <li class="disabled"><a href="#">&gt;</a></li>
                <li class="disabled"><a href="#">Last</a></li>
            </c:when>
            <c:otherwise>
                <li><a href="${page.url}?page=${page.number}&size=${page.size}&sort=${page.sort}">&gt;</a></li>
                <li><a href="${page.url}?page=${page.totalPages-1}&size=${page.size}&sort=${page.sort}">Last</a></li>
            </c:otherwise>
        </c:choose>
    </ul>
</div>